<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="18" :lg="7" :md="8" :sm="24">
            <!-- 仓库的详情 -->
            <div style="width: 100%">
              <p style="font-size: 18px;color: #2d2d2d;font-weight: bolder;float: left">{{goods_name}}</p>
              <p style="font-size: 13px;color: #656363;float: left;margin-left: 15px;margin-top: 3px">商品编号：{{goods_code}}</p>
              <p style="font-size: 13px;color: #656363;float: left;margin-left: 15px;margin-top: 3px">供应商商品编号：{{gongyingshang_code}}</p>
              <p style="font-size: 13px;color: #656363;float: right;margin-right: 12px;margin-top: 3px">待入库数量：{{wait_number}}</p>
            </div>
            <div style="width: 100%;overflow: hidden;margin-bottom: 10px;margin-top: -5px">
              <p style="font-size: 13px;color: #656363;float: left;">类型：{{type_name}}</p>
              <p style="font-size: 13px;color: #656363;float: left;margin-left: 15px;">单位：{{danwei}}</p>
              <p style="font-size: 13px;color: #656363;float: left;margin-left: 15px;">单价：{{dan_price}}</p>
            </div>
          </a-col>

<!--          <a-button type="primary" @click="increase_data(0)" icon="plus" style="color: #F9D532;width: 110px;height: 36px;background: #333333;border-style: none;float: right;margin-right: 16px;">配置入库</a-button>-->
        </a-row>
      </a-form>
    </div>

    <div style="background: #f2f2f2;height: 10px;width: auto;margin-top: 10px;margin-bottom: 30px;"></div>

    <div>
      <div style="border: none;background-color: #ffffff;padding-bottom: 28px;">
        <span style="font-size: 16px;float: left;color:#000000;font-weight: bold;margin-bottom: 10px">入库明细</span>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange" v-show="this.tabs==1" style="margin-top: -20px;">

        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="getAvatarView(record.img)" icon="img"/>
          </div>
        </template>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <div align="center" style="align-content: center;margin-left: 10px;">

           <a-menu-item style="margin-left: 10px;float: left;margin-top: 0px;">
            <a-popconfirm title="确定撤销该批次/匹号吗?" @confirm="() => edit_data_status(record.id,2)">
              <a style="font-size: 14px;color: #d29328;">撤销</a>
            </a-popconfirm>
          </a-menu-item>

          </div>
        </span>
      </a-table>
    </div>

    <AddpeizhiGoodsModule ref="modalForm" @ok="modalFormOk"></AddpeizhiGoodsModule>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {getAction,putAction,getFileAccessHttpUrl,httpAction} from '@/api/manage';
  import JDate from '@/components/jeecg/JDate.vue'
  import '@/assets/less/TableExpand.less'
  import AddpeizhiGoodsModule from './modules/AddpeizhiGoodsModule'

  export default {
    name: "categoryinfo",
    mixins:[JeecgListMixin],
    components: {
      JDate,
      AddpeizhiGoodsModule
    },
    data () {
      return {
        description: 'categoryinfo管理页面',
        tabs: 1,//切换框
        goods_name:'',
        goods_code:'',
        gongyingshang_code:'',
        wait_number:'',
        type_name:'',
        danwei:'',
        dan_price:'',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'批次/匹号',
            align:"center",
            dataIndex: 'batchName'
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'specificationsName'
          },
          {
            title:'尺码',
            align:"center",
            dataIndex: 'goodsSizeName'
          },
          {
            title:'入库数量',
            align:"center",
            dataIndex: 'incount'
          },
          {
            title:'库位信息',
            align:"center",
            dataIndex: 'locationName'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark',
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align:"center",
          //   width: 100,
          //   scopedSlots: { customRender: 'action' },
          // }
        ],
        url: {
          list: "/inventory/manger/ruku_goods_peizhiPagelist?topId="+this.$route.query.ruku_goodid+"&type=1",
          edit_cate_staus: "/inventory/manger/change_instorageitems_status",
          cangku_detail:"/inventory/manger/query_InstorageDan_goodsById"
        }
      }
    },
    created(){
      this.show_cangkuDetail();//查询入库单下的商品信息
    },
    methods: {
      getAvatarView: function (avatar) {
        return getFileAccessHttpUrl(avatar)
      },
      show_cangkuDetail(){//查询仓库详情
        let params = {id:this.$route.query.ruku_goodid};
        getAction(this.url.cangku_detail,params).then((res)=>{
          if(res.success){
            this.goods_name = res.result.goodsName;
            this.goods_code = res.result.goodsCode;
            this.gongyingshang_code = res.result.supplaygoodCode;
            this.type_name = res.result.goodtypeName;
            this.danwei = res.result.unit;
            this.dan_price = res.result.intoUnit;
            this.wait_number = res.result.remainingNumber;
          }
        });
      },
      increase_data(record) {
        if(record=='0'){
          this.$refs.modalForm.edit(record);
          this.$refs.modalForm.title = "配置入库项";
          this.$refs.modalForm.disableSubmit = true;
        }else {
          this.$refs.modalForm.edit(record);
          this.$refs.modalForm.title = "编辑入库项";
          this.$refs.modalForm.disableSubmit = true;
        }
      },
      set_reservoir(cangku_id){//配置货架
        this.$router.push({path:'/shelves/set',query: {kuqu_id:cangku_id}})
      },
      edit_data_status(id,status){//修改状态
        let params = {id:id,status:status};
        httpAction(this.url.edit_cate_staus,params,"put").then((res)=>{
          if(res.success){
            this.$message.success(res.message);
            this.loadData();
          }else {
            this.$message.error(res.message);
          }
        });
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>